package com.sd365.permission.centre.api.controller;

import com.sd365.common.core.common.exception.BusinessException;
import com.sd365.common.core.common.exception.code.CommonErrorCode;
import com.sd365.common.log.api.annotation.ApiLog;
import com.sd365.common.util.BeanUtil;
import com.sd365.permission.centre.api.RoleApi;
import com.sd365.permission.centre.entity.Node;
import com.sd365.permission.centre.entity.Role;
import com.sd365.permission.centre.pojo.dto.*;
import com.sd365.permission.centre.pojo.query.RoleQuery;
import com.sd365.permission.centre.pojo.query.UserQuery;
import com.sd365.permission.centre.pojo.vo.*;
import com.sd365.permission.centre.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
 * @Class RoleController
 * @Description 角色管理api 主要包含 角色的增删除改查以及角色和资源绑定，角色和用户绑定
 * @Author Administrator
 * @Date 2023-02-26  10:15
 * @version 1.0.0
 * TODO 负责模块的开发的人员需要开启注释代码实现接口
 */
@CrossOrigin
@RestController
public class RoleController implements RoleApi {

    @Autowired
    private RoleService roleService;



    @Override
    public Boolean initRoleResourceRedis(@NotNull Role role) {
        return null;
    }

    @Override
    public Boolean assignResource(@Valid RoleResourceDTO roleResourceDTO) {
        return null;
    }

    @Override
    public Boolean assignUser(@Valid UserRoleDTO userRoleDTO) {
        return null;
    }

    @Override
    public List<Node> doQueryResourceByRoleId(@NotNull RoleQuery roleQuery) {
        return null;
    }

    @Override
    public List<Node> selectCompany() {
        return null;
    }

    @Override
    public boolean haveRole(RoleDTO roleDTO) {
        return false;
    }

    @ApiLog
    @Override
    public Boolean add(@Valid RoleDTO roleDTO) {
        return roleService.add(roleDTO);
    }

    @Override
    public Boolean remove(@NotNull Long id, @NotNull Long version) {
        return null;
    }

    @Override
    public Boolean batchRemove(@NotNull RoleDTO[] roleDTOS) {
        return roleService.batchRemove(roleDTOS);
    }

    @Override
    public Boolean modify(@NotNull RoleDTO roleDTO) {
        return null;
    }

    @Override
    public RoleDTO copy(@NotNull Long id) {
        return null;
    }

    @ApiLog
    @Override
    public List<RoleVO> commonQuery(@NotNull RoleQuery roleQuery) {
        if(roleQuery == null) {
            throw new BusinessException(CommonErrorCode.SYSTEM_CONTROLLER_ARGUMENT_NOT_VALID,new Exception("查询对象参数不允许为空"));
        }
        /*
        执行查询语句
         */
        List<RoleDTO> roleDTOS = roleService.commonQuery(roleQuery);
        return BeanUtil.copyList(roleDTOS,RoleVO.class);
    }

    @Override
    public List<UserVO> commonQueryUser(@NotNull UserQuery userQuery) {
        return null;
    }

    @Override
    public RoleVO queryRoleById(Long id) {
        return null;
    }

    @Override
    public RoleVO queryUserResource(@NotNull Long id) {
        return null;
    }

    @Override
    public RoleCompanyVO queryRoleCompanyById(@NotNull Long id) {
        return null;
    }

    @Override
    public Boolean modifyRoleCompany(@Valid RoleCompanyDTO roleCompanyDTO) {
        return null;
    }
}
